package com.cloud.force.interfaces;

import com.cloud.force.api.entity.Media;
import com.cloud.force.common.config.FeignConfiguration;
import feign.hystrix.FallbackFactory;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import java.util.List;

/**
 * @program: quokka-server
 * @description: ${description}
 * @author: sl
 * @create: 2019-08-12 15:45
 **/
@FeignClient(value = "MEDIA",  configuration = FeignConfiguration.class, fallbackFactory = FeignClientMediaFallbackFactory.class)
public interface FeignClientMedia {

    /**
     * 获取字典项
     * @return
     */
    @RequestMapping(value = "media/interface/getAllMediaByIds", method = RequestMethod.GET)
    List<Media> getAllMediaByIds(@RequestBody List<String> ids);

}

@Component
class FeignClientMediaFallbackFactory implements FallbackFactory<FeignClientMedia> {

    @Override
    public FeignClientMedia create(final Throwable cause) {
        return new FeignClientMedia() {

            @Override
            public List<Media> getAllMediaByIds(List<String> ids) {
                return null;
            }
        };
    }
}